<template>
	<el-form ref="form" label-width="150px">
		<el-form-item :label="item.content" v-for="(item,index) in sys" :key="index" label-width="150px">
		    <el-input v-model="sys[index].value" v-if="item.switch==0"></el-input>
			<el-radio-group v-model="sys[index].value" v-if="item.switch==2">
			    <el-radio  v-for="(item1,index1) in item.other" :key="index1" :label="index1">{{item1}}</el-radio>
			  </el-radio-group>
			   <el-input v-model="sys[index].value" v-if="item.switch==5" type="textarea"></el-input>
			  <el-switch v-if="item.switch==1"
			    v-model="sys[index].value"
			    active-color="#13ce66"
			    inactive-color="#ff4949">
			  </el-switch>
			  <div v-if="item.switch==4">
				  <Pic :url="sys[index].value" :index="index" @get_url="get_url" @delImg="delimg"></Pic>
			  </div>
			  
			   <el-color-picker v-if="item.switch==6" v-model="item.value"></el-color-picker>
				 
		  </el-form-item>
		  <el-form-item>
		      <el-button type="primary" @click="onSubmit">提交</el-button>
		    </el-form-item>
	</el-form>
</template>

<script>
	import Pic from '../../components/UploadPicOne.vue'
	import {Api_url} from '../../api/config.js'
	export default {
	  data() {
	    return {
			form:[],
			img:Api_url,
			name:'',
			drawer:false,
			img_choose_index:''
	  }	
	},
	components:{
		Pic
	},
	props: {
		sys:{
			type:Array,
			default:()=>{
				return []
			}
		},
	},

	mounted() {
		
	},
	methods: {
		onSubmit(){
			
			this.$model.post("/cms/sys/update",this.sys).then(res=>{
				this.$message({
				         message: '修改成功',
				         type: 'success'
				       });
			})
		
		},
		delimg(index){
			this.sys[index].value=''
		},
		get_url(e){
			console.log(e)
			this.sys[e.index].value=e.url;
		},
		get_img(e){
			this.sys[this.img_choose_index].value=e.url
				this.drawer=false
		},
		back(e){
			this.drawer=false
		},
		choose_pic(index){
			this.img_choose_index=index
			this.drawer=true
		}
	}
	}
</script>

<style>
	.picA {
		width: 148px;
		height: 148px;
		background-color: #FBFDFF;
		border: 1px dashed #C0CCDA;
		border-radius: 6px;
		box-sizing: border-box;
		vertical-align: top;
		text-align: center;
		margin: 6px;
	}
	
	.img {
		width: 144px;
		height: 144px;
		border: 1px solid #BFBFBF;
		border-radius: 3px;
	}
</style>
